package rentel.logbook.user;

import rentel.logbook.common.Md5Hasher;
import rentel.logbook.persistence.IRowBuilder;
import rentel.logbook.persistence.LogbookUserDB;

/**
 * Registration logbook user holder
 * @author Jiri Styblo
 *
 */
public class LogbookUser implements IRowBuilder{

	private String name;
	private String surname;
	private String userName;
	private String userPassword;
	private String userPassword1;
	
	public LogbookUser() {
		// NOP
	}
	
	public LogbookUser(
		String name, 
		String surname, 
		String userName,
		String userPassword,
		String userPassword1
	) {
		this.name = name;
		this.surname = surname;
		this.userName = userName;
		this.userPassword = userPassword;
		this.userPassword1 = userPassword1;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}
	
	public String getUserPassword1() {
		return userPassword1;
	}

	public void setUserPassword1(String userPassword1) {
		this.userPassword1 = userPassword1;
	}

	@Override
	public String toString () {
		return "LogbookUser [name=" + name + ", surname=" + surname
			+ ", userName=" + userName + ", userPassword=" + userPassword
			+ ", userPassword1=" + userPassword1 + "]";
	}

	public Object buildRow() {

		String md5Password = Md5Hasher.md5AsString(userPassword);

		return new LogbookUserDB(name, surname, userName, md5Password);

	}
	
}
